//---------------------------------------------------------------------------
#ifndef ConfiguratorH
#define ConfiguratorH
//---------------------------------------------------------------------------
#include <Classes.hpp>
#include <Controls.hpp>
#include <StdCtrls.hpp>
#include <Forms.hpp>
#include "YbCommDevice.h"
#include <ComCtrls.hpp>
#include <ExtCtrls.hpp>
//---------------------------------------------------------------------------
class TFormMain : public TForm
{
__published:	// IDE-managed Components
	TYbCommDevice *YbComm1;
	TButton *ButtonCommSetting;
	TButton *ButtonCommActive;
	TMemo *MemoSend;
	TMemo *MemoReceive;
	TPageControl *PageControl1;
	TTabSheet *TabSheet1;
	TGroupBox *GroupBox1;
	TLabel *Label1;
	TLabel *Label2;
	TLabel *Label3;
	TEdit *EditZigbeeSend;
	TButton *ButtonZigbeeSend;
	TEdit *EditCompSend;
	TButton *ButtonCompSend;
	TEdit *EditFreeSend;
	TButton *ButtonFreeSend;
	TCheckBox *CheckBoxFreeCheck;
	TButton *Button_ClearRecMemo;
	TButton *Button_ClearSendMemo;
	TButton *Button_PollTimerEanble;
	TEdit *Edit_TimPollInterval;
	TRadioGroup *RadioGroup_ReceiveType;
	TLabel *Label_NumReadByte;
	TTabSheet *TabSheet2;
	TButton *ButtonTXTSend;
	TMemo *MemoTXTSend;
	TButton *ButtonClearTXTSend;
	TCheckBox *CheckBoxFreeSend;
	TCheckBox *CheckBoxCompSend;
	TCheckBox *CheckBoxZigbeeSend;
	TTimer *Timer_ContSend;
	TEdit *Edit_TimContInterval;
	TButton *Button_ContTimerEnable;
	TCheckBox *CheckBoxTXTSend;
	TCheckBox *CheckBoxMemoRecShow;
	TButton *ButtonSimComp;
	TButton *ButtonClearSend;
	TTabSheet *TabSheet3;
	TRadioGroup *RadioGroupReadType;
	TTabSheet *TabSheet4;
	TGroupBox *GroupBoxReadMotor;
	TLabel *Label4;
	TLabel *Label5;
	TEdit *Edit_ReadMotorID;
	TButton *Button_ReadMotor;
	TLabel *Label6;
	TLabel *Label_ReadPosition;
	TLabel *Label_ReadVoltage;
	TLabel *Label7;
	TLabel *Label_ReadError;
	TButton *ButtonSimWriteMotor;
	void __fastcall ButtonCommSettingClick(TObject *Sender);
	void __fastcall ButtonCommActiveClick(TObject *Sender);
	void __fastcall FormCreate(TObject *Sender);
	//void __fastcall YbComm1CommNotify(TObject *Sender, int NotifyType);
	void __fastcall EditZigbeeSendKeyPress(TObject *Sender, wchar_t &Key);
	void __fastcall EditCompSendKeyPress(TObject *Sender, wchar_t &Key);
	void __fastcall EditFreeSendKeyPress(TObject *Sender, wchar_t &Key);
	void __fastcall Button_ClearRecMemoClick(TObject *Sender);
	void __fastcall Button_ClearSendMemoClick(TObject *Sender);
	void __fastcall Button_PollTimerEanbleClick(TObject *Sender);
	void __fastcall Edit_TimPollIntervalKeyPress(TObject *Sender, wchar_t &Key);
	void __fastcall ButtonZigbeeSendClick(TObject *Sender);
	void __fastcall ButtonFreeSendClick(TObject *Sender);
	void __fastcall ButtonCompSendClick(TObject *Sender);
	void __fastcall ButtonTXTSendClick(TObject *Sender);
	void __fastcall MemoTXTSendKeyDown(TObject *Sender, WORD &Key, TShiftState Shift);
	void __fastcall ButtonClearTXTSendClick(TObject *Sender);
	void __fastcall Edit_TimContIntervalKeyPress(TObject *Sender, wchar_t &Key);
	void __fastcall Button_ContTimerEnableClick(TObject *Sender);
	void __fastcall Timer_ContSendTimer(TObject *Sender);
	void __fastcall CheckBoxZigbeeSendClick(TObject *Sender);
	void __fastcall CheckBoxCompSendClick(TObject *Sender);
	void __fastcall CheckBoxFreeSendClick(TObject *Sender);
	void __fastcall CheckBoxTXTSendClick(TObject *Sender);
	void __fastcall ButtonZigbeeSendMouseDown(TObject *Sender, TMouseButton Button,
          TShiftState Shift, int X, int Y);
	void __fastcall ButtonCompSendMouseDown(TObject *Sender, TMouseButton Button, TShiftState Shift,
          int X, int Y);
	void __fastcall ButtonFreeSendMouseDown(TObject *Sender, TMouseButton Button, TShiftState Shift,
          int X, int Y);
	void __fastcall ButtonTXTSendMouseDown(TObject *Sender, TMouseButton Button, TShiftState Shift,
          int X, int Y);
	void __fastcall MemoReceiveDblClick(TObject *Sender);
	void __fastcall ButtonSimCompClick(TObject *Sender);
	void __fastcall ButtonClearSendClick(TObject *Sender);
	void __fastcall Button_ReadMotorClick(TObject *Sender);
	void __fastcall Edit_ReadMotorIDKeyPress(TObject *Sender, wchar_t &Key);
	void __fastcall ButtonSimWriteMotorClick(TObject *Sender);
	void __fastcall FormDestroy(TObject *Sender);


private:	// User declarations
public:		// User declarations
	__fastcall TFormMain(TComponent* Owner);

	int bound_int(int lower, int upper, int value);
	void Initial_CommPort();
	void Clear_TX(unsigned char* TX, int TX_length);
	bool StringToTX(AnsiString str_TX, unsigned char* TX, int TX_length);
	bool ReadMotor_DataCheck(unsigned char* buf, int length_buf);
	void AccessReadBuf();
};
//---------------------------------------------------------------------------
extern PACKAGE TFormMain *FormMain;
//---------------------------------------------------------------------------
#endif
